package com.blog.backend.controller;

import com.blog.backend.domain.BlogUser;
import com.blog.backend.service.UserService;
import com.blog.common.annotation.Anonymous;
import com.blog.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Auman
 * @time 2024/4/27 23:49
 */
@Api("用户操作controller")
@RequestMapping("/backend/user")
@RestController
public class UserController {

    @Autowired
    private UserService service;

    @Anonymous
    @ApiOperation("新增用户")
    @PostMapping("/addUser")
    public R addUser(@Validated @RequestBody BlogUser user) {
        int i = service.addUser(user);
        if (i <= 0 ) {
            return R.fail("新增用户失败");
        }
        return R.ok();
    }

}
